<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE topic
  PUBLIC "-//OASIS//DTD DITA Composite//EN" "ditabase.dtd">
<topic id="topic1" xml:lang="en"><title id="ga143896">pg_attribute</title><body><p>The <codeph>pg_attribute</codeph> table stores information about table columns. There will be
      exactly one <codeph>pg_attribute</codeph> row for every column in every table in the database.
      (There will also be attribute entries for indexes, and all objects that have
        <codeph>pg_class</codeph> entries.) The term attribute is equivalent to column.</p><table id="ga143898"><title>pg_catalog.pg_attribute</title><tgroup cols="4"><colspec colnum="1" colname="col1" colwidth="131pt"/><colspec colnum="2" colname="col2" colwidth="86pt"/><colspec colnum="3" colname="col3" colwidth="85pt"/><colspec colnum="4" colname="col4" colwidth="147pt"/><thead><row><entry colname="col1">column</entry><entry colname="col2">type</entry><entry colname="col3">references</entry><entry colname="col4">description</entry></row></thead><tbody><row><entry colname="col1"><codeph>attrelid</codeph></entry><entry colname="col2">oid</entry><entry colname="col3">pg_class.oid</entry><entry colname="col4">The table this column belongs to.</entry></row><row><entry colname="col1"><codeph>attname</codeph></entry><entry colname="col2">name</entry><entry colname="col3"/><entry colname="col4">The column name.</entry></row><row><entry colname="col1"><codeph>atttypid</codeph></entry><entry colname="col2">oid</entry><entry colname="col3">pg_type.oid</entry><entry colname="col4">The data type of this column.</entry></row><row><entry colname="col1"><codeph>attstattarget</codeph></entry><entry colname="col2">int4</entry><entry colname="col3"/><entry colname="col4">Controls the level of detail of statistics accumulated
for this column by <codeph>ANALYZE</codeph>. A zero value indicates that
no statistics should be collected. A negative value says to use the system
default statistics target. The exact meaning of positive values is data
type-dependent. For scalar data types, it is both the target number of
"most common values" to collect, and the target number of histogram
bins to create.</entry></row><row><entry colname="col1"><codeph>attlen</codeph></entry><entry colname="col2">int2</entry><entry colname="col3"/><entry colname="col4">A copy of <codeph>pg_type.typlen</codeph> of this column's
type.</entry></row><row><entry colname="col1"><codeph>attnum</codeph></entry><entry colname="col2">int2</entry><entry colname="col3"/><entry colname="col4">The number of the column. Ordinary columns are
numbered from 1 up. System columns, such as oid, have (arbitrary) negative
numbers.</entry></row><row><entry colname="col1"><codeph>attndims</codeph></entry><entry colname="col2">int4</entry><entry colname="col3"/><entry colname="col4">Number of dimensions, if the column is an array
type; otherwise <codeph>0</codeph>. (Presently, the number of dimensions
of an array is not enforced, so any nonzero value effectively means it
is an array.)</entry></row><row><entry colname="col1"><codeph>attcacheoff</codeph></entry><entry colname="col2">int4</entry><entry colname="col3"/><entry colname="col4">Always <codeph>-1</codeph> in storage, but when
loaded into a row descriptor in memory this may be updated to cache the
offset of the attribute within the row.</entry></row><row><entry colname="col1"><codeph>atttypmod</codeph></entry><entry colname="col2">int4</entry><entry colname="col3"/><entry colname="col4">Records type-specific data supplied at table
creation time (for example, the maximum length of a <codeph>varchar</codeph> column).
It is passed to type-specific input functions and length coercion functions.
The value will generally be <codeph>-1</codeph> for types that do not
need it.</entry></row><row><entry colname="col1"><codeph>attbyval</codeph></entry><entry colname="col2">boolean</entry><entry colname="col3"/><entry colname="col4">A copy of <codeph>pg_type.typbyval</codeph> of this
column's type.</entry></row><row><entry colname="col1"><codeph>attstorage</codeph></entry><entry colname="col2">char</entry><entry colname="col3"/><entry colname="col4">Normally a copy of <codeph>pg_type.typstorage</codeph>
of this column's type. For TOAST-able data types, this can be altered
after column creation to control storage policy.</entry></row><row><entry colname="col1"><codeph>attalign</codeph></entry><entry colname="col2">char</entry><entry colname="col3"/><entry colname="col4">A copy of <codeph>pg_type.typalign</codeph> of this
column's type.</entry></row><row><entry colname="col1"><codeph>attnotnull</codeph></entry><entry colname="col2">boolean</entry><entry colname="col3"/><entry colname="col4">This represents a not-null constraint. It is
possible to change this column to enable or disable the constraint.</entry></row><row><entry colname="col1"><codeph>atthasdef</codeph></entry><entry colname="col2">boolean</entry><entry colname="col3"/><entry colname="col4">This column has a default value, in which case
there will be a corresponding entry in the <codeph>pg_attrdef</codeph> catalog
that actually defines the value.</entry></row><row><entry colname="col1"><codeph>attisdropped</codeph></entry><entry colname="col2">boolean</entry><entry colname="col3"/><entry colname="col4">This column has been dropped and is no longer
valid. A dropped column is still physically present in the table, but
is ignored by the parser and so cannot be accessed via SQL.</entry></row><row><entry colname="col1"><codeph>attislocal</codeph></entry><entry colname="col2">boolean</entry><entry colname="col3"/><entry colname="col4">This column is defined locally in the relation.
Note that a column may be locally defined and inherited simultaneously.</entry></row><row><entry colname="col1"><codeph>attinhcount</codeph></entry><entry colname="col2">int4</entry><entry colname="col3"/><entry colname="col4">The number of direct ancestors this column has.
A column with a nonzero number of ancestors cannot be dropped nor renamed.</entry></row>
    <row>
      <entry colname="col1"><codeph>attcollation</codeph></entry>
      <entry colname="col2">oid</entry>
      <entry colname="col3">pg_collation.oid</entry>
      <entry colname="col4">The defined collation of the column, or zero if the
        is not of a collatable data type.</entry>
    </row>
    <row>
      <entry colname="col1"><codeph>attacl</codeph></entry>
      <entry colname="col2">aclitem[]</entry>
      <entry colname="col3"></entry>
      <entry colname="col4">Column-level access privileges, if any have been
        granted specifically on this column.</entry>
    </row>
    <row>
      <entry colname="col1"><codeph>attoptions</codeph></entry>
      <entry colname="col2">text[]</entry>
      <entry colname="col3"></entry>
      <entry colname="col4">Attribute-level options, as "keyword=value" strings.</entry>
    </row>
    <row>
      <entry colname="col1"><codeph>attfdwoptions</codeph></entry>
      <entry colname="col2">text[]</entry>
      <entry colname="col3"></entry>
      <entry colname="col4">Attribute-level foreign data wrapper options, as
        "keyword=value" strings.</entry>
    </row>
</tbody></tgroup></table></body></topic>
